<template>
  <h1>猜数字练习</h1>
  <input type="text" style="width:500px" placeholder="请输入您所猜的
  数字(1~100之间的整数),并按回车键进行确认" v-model="guess" @keydown.enter="ent">
</template>

<script setup>
  let num = parseInt(Math.random()*100)+1;
  console.log(num)
  let count = 0;
  import {ref} from "vue";

  const guess = ref('');
  const message = ref('');
  const ent = ()=>{
    count++;
    if(num<guess.value){
      message.value = alert("猜大了");
      guess.value = '';
    }else if(num>guess.value){
      message.value = alert("猜小了")
      guess.value = '';
    }else {
      message.value = alert("恭喜你用了"+count+"次就猜对了");
    }
  }
</script>

<style scoped>

</style>